    public class Keben {
    public int nthUglyNumber(int n) {
        TreeSet<Long> set = new TreeSet<Long>();
        int count = 0;
        long result = 1;
        set.add(result);
        while (count < n) {
            result = set.pollFirst();
            count++;
            set.add(result * 2);
            set.add(result * 3);
            set.add(result * 5);
        }
        return (int) result;
    }

}